<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
    <div id="app">
        methosd方法:{{getMes()}} computed方法：{{Mes}} watch方法：我叫{{mes.name}},我来自{{mes.city}}
    </div>
    <script type="text/javascript">
        const vm = new Vue({
            el: '#app',
            data() {
                return {
                    txt: '',
                    mes: {
                        name: "张三",
                        city: "北京"
                    }
                }
            },
            methods: {
                getMes() {
                    return "我叫" + this.mes.name + ",我来自" + this.mes.city;
                }
            },
            computed: {
                Mes() {
                    return "我叫" + this.mes.name + ",我来自" + this.mes.city;
                }
            },
            watch: {
                mes(item1, item2) {
                    console.log(item1);
                    console.log(item2);
                },
                immediate: true,
            }
        })
    </script>
</body>

</html>